﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Rechargeable.Migrations
{
    public partial class machine_v1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppMachines",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    Name = table.Column<string>(maxLength: 256, nullable: true),
                    Desc = table.Column<string>(nullable: true),
                    DriveId = table.Column<string>(maxLength: 128, nullable: false),
                    ExpireTime = table.Column<DateTime>(nullable: false),
                    LastOnlineTime = table.Column<DateTime>(nullable: false),
                    AutoRecharge = table.Column<bool>(nullable: false, defaultValue: true),
                    UserId = table.Column<Guid>(nullable: false),
                    ProductId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppMachines", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppMachines_ProductId",
                table: "AppMachines",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_AppMachines_UserId",
                table: "AppMachines",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_AppMachines_UserId_ProductId",
                table: "AppMachines",
                columns: new[] { "UserId", "ProductId" });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppMachines");
        }
    }
}
